home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGBLER / ASMCODE2.LZH / SWPTR.ASM < prev    next >
Assembly Source File  |  1983-08-24  |  5KB  |  163 lines

  1.     PAGE    60,132
  2.     TITLE    SWPTR - SWAP LPT1: AND LPT2: POINTERS
  3.     COMMENT \
  4.  
  5.         COPYRIGHT 1983 by    Thomas M. Rowlett
  6.                     11296 Windsor Court
  7.                     Ijamsville, Maryland  21754
  8.                     (301) 831-9382
  9.  
  10.         This program exchanges the printer addresses for LPT1: and
  11.         LPT2: in the BIOS Data Area (see page 3-7 of the IBM
  12.         Personal Computer Technical Reference Manual for further
  13.         information).
  14.  
  15.         This program is made available to all members of the Capital
  16.         PC Users Group for their own personal use and not for resale
  17.         in any manner.    The program may be modified and distributed
  18.         but it is requested that the original copyright remain in the
  19.         program.
  20.  
  21.         \
  22. ;
  23. INTPTR    MACRO    PTRID            ;Call to DOS to initialize the printer
  24.     XOR    DX,DX            ;Clear DX register
  25.     MOV    DX,PTRID-1        ;Setup printer ID in register DX
  26.     MOV    AH,01H            ;Set high-order byte of accumulator to
  27. ;                     initialize  the printer specified by DX
  28.     INT    17H            ;printer interrupt call to BIOS in ROM
  29. ;
  30.     ENDM
  31. ;
  32. PRINT    MACRO    MESSAGE
  33.     MOV    DX,OFFSET MESSAGE    ;pointer to message
  34.     MOV    AH,09H            ;set screen function
  35.     INT    21H            ;go to DOS
  36. ;
  37.     ENDM
  38. ;
  39. DATA    SEGMENT AT 40H
  40. RS232    DW    4 DUP (?)        ;ADDRESSES OF RS-232 POINTERS
  41. LPT1    DW    ?            ;ADDRESS OF LPT1: POINTER
  42. LPT2    DW    ?            ;ADDRESS OF LPT2: POINTER
  43. DATA    ENDS
  44. SUBTTL    MAIN PROGRAM SECTION
  45.     PAGE
  46. CSEG    SEGMENT PARA PUBLIC 'CODE'
  47. START    PROC    FAR
  48.     ASSUME    CS:CSEG,DS:CSEG,ES:DATA
  49.     ORG    5DH            ;ESTABLISH ADDRESS TO GET INPUT PARMS
  50. PARM    DB    ?            ;PARM TO INSPECT SETTING
  51.     ORG    100H            ;BEGIN CODING SECTION
  52. BEGIN:    MOV    AX,DATA         ;INITIALIZE 'ES' REGISTER
  53.     MOV    ES,AX
  54. ;
  55.     PRINT    MSG1            ;PRINT INTRODUCTORY MESSAGE/HEADER
  56.     MOV    AL,PARM         ;GET INPUT PARAMETER
  57.     CMP    AL,'I'                  ;TEST FOR INSPECT
  58.     JNE    SWAPTM            ;GO TO SWAP THE POINTERS
  59.     PRINT    MSG5            ;PRINT INSPECT TITLE
  60.     CALL    PTMSG2            ;GO PRINT POINTER VALUES
  61.     PRINT    INSPMSG         ;ALL DONE - Print inspect end message
  62.     INT    20H            ;Return to DOS
  63. ;
  64. SWAPTM: PRINT    MSG3            ;Print 'before -' on screen
  65.     CALL    PTMSG2            ;DISPLAY BEGINNIG STATUS OF POINTERS
  66. ;
  67. ;    SWAP POINTERS
  68. ;
  69.     MOV    DX,LPT1         ;move pointer for LPT1: to DX register
  70.     MOV    AX,LPT2         ;move pointer for LPT2: to AX register
  71.     MOV    LPT1,AX         ;move old LPT2: pointer to LPT1: pointer
  72.     MOV    LPT2,DX         ;move old LPT1: pointer to LPT2: pointer
  73. ;
  74.     OR    AX,AX            ;TEST FOR LPT1: PRESENT
  75.     JZ    SWPT01            ;BYPASS INITIALIZATION IF NOT PRESENT
  76.     INTPTR    1            ;INITIALIZE printer LPT1:
  77. SWPT01: MOV    AX,LPT2         ;TEST FOR LPT2: PRESENT
  78.     JZ    SWPT02            ;BYPASS INITIALIZATION IF NOT PRESENT
  79.     INTPTR    2            ;Initialize printer LPT2:
  80. SWPT02: PRINT    MSG4            ;Print 'after -' on screen
  81.     CALL    PTMSG2            ;DISPLAY RESULT OF SWAP
  82.     PRINT    ENDMSG            ;DISPLAY SALUTATION
  83. ;
  84. ;
  85. EXIT:    INT    20H            ;RETURN TO DOS
  86. ;
  87. ;
  88. PTMSG2    PROC    NEAR
  89. ;
  90. ;    SUBROUTINE TO PRINT STATUS OF POINTERS
  91. ;
  92.     MOV    BX,LPT1
  93.     MOV    AL,BH            ;CONVERT HIGH-ORDER BYTE OF LPT1:
  94.     CALL    HEXCHAR
  95.     MOV    PL1,AX
  96.     MOV    AL,BL            ;CONVERT LOW-ORDER BYTE OF LPT1:
  97.     CALL    HEXCHAR
  98.     MOV    PL2,AX
  99.     MOV    BX,LPT2
  100.     MOV    AL,BH            ;CONVERT HIGH-ORDER BYTE OF LPT2:
  101.     CALL    HEXCHAR
  102.     MOV    PL3,AX
  103.     MOV    AL,BL            ;CONVERT LOW-ORDER BYTE OF LPT2:
  104.     CALL    HEXCHAR
  105.     MOV    PL4,AX
  106.     PRINT    MSG2            ;PRINT ADDRESSES TO DISPLAY
  107.     RET
  108. PTMSG2    ENDP
  109. ;
  110. ;
  111. HEXCHAR PROC    NEAR
  112. ;
  113. ;    SUBROUTINE TO CONVERT ONE BYTE TO 2 HEX CHARACTERS
  114. ;    Characters are returned in AX register in reverse order so that
  115. ;    a MOV x,AX will store the characters in their proper order in 'x'
  116. ;
  117.     XOR    AH,AH            ;Clear work register (high-order byte)
  118.     CALL    HXBYTE            ;Convert first four bits to hex char and
  119. ;                     store in AH
  120.     MOV    DH,AH            ;Save high-order character in DH
  121. ;                     temporarily
  122.     XOR    AH,AH            ;Clear AH again
  123.     CALL    HXBYTE            ;Convert low-order four bits and
  124. ;                     save in AH
  125.     MOV    AL,DH            ;move high-order character back
  126. ;                     into low-order of AX
  127.     RET                ;return with AX set LLHH
  128. HEXCHAR ENDP
  129. ;
  130. ;
  131. HXBYTE    PROC    NEAR
  132. ;
  133. ;    SUBROUTINE TO CONVERT HEX CHAR IN AL TO DISPLAY HEX IN AH
  134. ;
  135.     MOV    CL,04H            ;set shift count register
  136.     SHL    AX,CL            ; shift ax left 4 bits or positions
  137.     OR    AH,30H            ; make it an ASCII number (e.g. 30 - 3F)
  138.     CMP    AH,3AH            ;check for less than a hex 3A
  139.     JB    HXCEX            ;it is -- get out
  140.     ADD    AH,07H            ;make it an ASCII 'A' to 'F' then
  141. HXCEX:    RET                ;exit
  142. HXBYTE    ENDP
  143. ;
  144. ;
  145. MSG1:    DB    'SWAP LPT1: AND LPT2: ADDRESS POINTERS IN BIOS DATA AREA'
  146.     DB    13,10,10
  147.     DB    '               LPT1:     LPT2:',13,10,'$'
  148. MSG2    DB    '      '
  149. PL1:    DW    'XX'
  150. PL2:    DW    'XX'
  151.     DB    '      '
  152. PL3:    DW    'XX'
  153. PL4:    DW    'XX'
  154.     DB    13,10,'$'
  155. MSG3:    DB    'Before - ','$'
  156. MSG4:    DB    'After  - ','$'
  157. MSG5:    DB    'Inspect  ','$'
  158. ENDMSG    DB    10,'LPT1: and LPT2: POINTERS SWAPPED',13,10,'$'
  159. INSPMSG DB    10,'$'
  160. START    ENDP
  161. CSEG    ENDS
  162.     END    BEGIN
  163.